import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-17
 * Time: 22:21
 */
public class Test63 {

    static List<List<String>> ret;
    static int n1;
    static boolean[] dig1, dig2, checkCol;
    static char[][] path;

    public static List<List<String>> solveNQueens(int n) {
        ret = new ArrayList<>();
        n1 = n;
        dig1 = new boolean[2 * n1];
        dig2 = new boolean[2 * n1];
        checkCol = new boolean[n];
        path = new char[n1][n1];
        for (int i = 0; i < n1; i++) {
            Arrays.fill(path[i], '.');
        }
        dfs(0);
        return ret;
    }
    public static void dfs(int row) {
        if(row == n1) {
            List<String> tmp = new ArrayList<>();
            for(int i = 0; i < n1; i++) {
                tmp.add(new String(path[i]));
            }
            ret.add(new ArrayList<>(tmp));
        }
        for(int col = 0; col < n1; col++) {
            if(!checkCol[col] && !dig2[row-col+n1] && !dig1[row+col]) {
                path[row][col] = 'Q';
                checkCol[col] = dig2[row-col+n1] = dig1[row+col] = true;
                dfs(row+1);
                path[row][col] = '.';
                checkCol[col] = dig2[row-col+n1] = dig1[row+col] = false;
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<List<String>> ret = solveNQueens(n);
        System.out.println(ret);
    }
}